package com.atguigui.leetcode;

/**
 * 1668.最大重复子字符串
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2022/11/3 16:57
 */
public class P1668MaximumRepeatingSubstring {
    public static void main(String[] args) {
        Solution solution = new P1668MaximumRepeatingSubstring().new Solution();
        String str = "aaabaaaabaaabaaaabaaaabaaaabaaaaba";
        System.out.println(solution.maxRepeating(str, "aaaba"));
        // TO TEST
    }

    class Solution {
        public int maxRepeating(String sequence, String word) {
            String s = word;
            int ans = 0;
            while (sequence.contains(s)) {
                ans++;
                s += word;
            }
            return ans;
        }
    }
}
